#ifndef EPOLL_HPP_
#define EPOLL_HPP_

#include "Common.hpp"
#include "ThreadPool.hpp"
#include "HTTP_Request.hpp"
#include "timer.hpp"

class Epoll{
private:
    int ep_fd;
    struct epoll_event events[EPOLL_SIZE];
    int event_num;

public:
    Epoll() : ep_fd(0) {}
    void create();  // 创建epoll
    void add_fd(HTTP_Request* _req, int fd, bool IsEdgeTrigger);    // 添加fd到epoll的监听事件
    void mod_fd(HTTP_Request *_req);
    void add_listen_fd(int listen_fd);
    // epoll_wait 返回就绪事件的数量
    void wait_for_event(int timeout);
    void handle_event(Timer_Queue &timer_queue, int listen_fd, ThreadPool& threadpool, void (*func)(void* arg));
    void accept_connection(Timer_Queue &timer_queue, int fd);
    int get_epoll_fd(){
        return ep_fd;
    }
};

#endif